package com.hushao.aimi.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * @description: 商品信息
 * @author: 胡少
 * @create: 2018-06-03 16:17
 **/
@Entity
@ApiModel("商品信息")
@Data
public class AimiProduct {

    @Id
    @GenericGenerator(name = "uuid",strategy = "uuid")
    @GeneratedValue(generator = "uuid")
    @Column(length = 32)
    private String id;

    /**
     * 商品编号
     */
    @Column(length = 16,nullable = false,unique = true)
    @Size(min = 6,message = "编号长度不符")
    private String productCode;

    /**
     * 分类id
     */
    @Column(nullable = false)
    private Integer categoryId;

    /**
     * 商品名称
     */
    @NotNull(message = "商品名称不能为空")
    @Column(length = 128,nullable = false)
    private String name;

    @ApiModelProperty("商品副标题")
    @Column(length = 256)
    private String subtitle;


    /**
     * 商品副图片URL地址
     */
    @Lob
    @Basic(fetch = FetchType.LAZY)
    private String subImages;

    /**
     * 商品详细
     */
    @Lob
    @Basic(fetch = FetchType.LAZY)
    private String detail;

    /**
     * 商品状态：0-删除；1-在售;2-下架
     */
    @Column(nullable = false,length = 2)
    private int status;

    /**
     * 排序
     */
    @Column(length = 11)
    private Integer sortOrder=999999999;

    @CreationTimestamp
    private Timestamp createTime;

    @UpdateTimestamp
    private Timestamp updateTime;

    @Column(length = 512)
    private String comment;

    public AimiProduct(Integer categoryId, @NotNull(message = "商品名称不能为空") String name, String subtitle, String subImages, String detail, byte status, Integer sortOrder, Timestamp createTime, Timestamp updateTime, String comment) {
        this.categoryId = categoryId;
        this.name = name;
        this.subtitle = subtitle;
        this.subImages = subImages;
        this.detail = detail;
        this.status = status;
        this.sortOrder = sortOrder;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.comment = comment;
    }
}
